About object files

Object files define what is created by the buttons on the Object panel and the items in the Insert menu. You can create your own object files or modify the files included with Dreamweaver. Object files are stored on your hard drive in Dreamweaver/Configuration/Objects. Inside the Objects directory are subdirectories called Common, Forms, and Invisibles that group the objects into panels. Inside these subdirectories are the HTML files that define objects.

You can edit existing objects or create new ones using Dreamweaver or a text editor (for example, BBEdit, HomeSite, NotePad, or SimpleText). You must quit and relaunch Dreamweaver before any new objects will be accessible.

There are three main components to Objects: (1) the object file that defines what is inserted in your document; (2) the entry in InsertMenu.htm that defines how the object appears in the Insert menu, what its keyboard shortcut is, and what its Windows mnemonic is; and (3) the 16-pixel by 16-pixel GIF image that appears in the Objects palette.


The object file
The object file contains the HTML that is inserted in your document when you click the object's icon in the Object palette, or when you select the object's name from the Insert menu.

The easiest way to create a new object is to save a file with only the tags you want to be inserted. For example you could create a file called tic_tac_toe.htm that contained only

<TABLE CELLSPACING="2" CELLPADDING="5" BORDER="2">
<TR VALIGN="middle" ALIGN="center">
<TD><FONT COLOR="#FF0000">X</FONT></TD>
<TD>O</TD>
<TD>O</TD>
</TR>
<TR VALIGN="middle" ALIGN="center">
<TD>O</TD>
<TD><FONT COLOR="#FF0000">X</FONT></TD>
<TD>X</TD>
</TR>
<TR VALIGN="middle" ALIGN="center">
<TD>X</TD>
<TD>O</TD>
<TD><FONT COLOR="#FF0000">X</FONT></TD>
</TR>
</TABLE>

When you clicked on the Tic Tac Toe icon in the Object palette or selected Tic Tac Toe from the Insert menu, this table would be inserted into your document.

You can also use a JavaScript function called objectTag() to insert HTML into your document (all the objects that ship with Dreamweaver use the objectTag() function). For example, the Horizontal Rule object's objectTag() function looks like this:

function objectTag() {
return "<HR>"	
}

To add line breaks and other white space between the returned tags, break the tags into separate strings (the part enclosed in single quotes), each with a \n at the end to indicate a line break, and then concatenate the strings with plus (+) signs. For example:

function objectTag() {
return '\n' +
'<OBJECT CLASSID="clsid:166F1OOB-3A9R-11FB-8075444553540000" \n' +
'CODEBASE="http://www.mysite.com/product/cabs/myproduct.cab#version=1,0,0,0" \n' +
'NAME="MyProductName"> \n' +
'<PARAM NAME="SRC" VALUE=""> \n' +
'<EMBED SRC="" HEIGHT= WIDTH= NAME="MyProductName"> \n' +
'</OBJECT>'
}

Objects can have forms that let you enter parameters to the object before it is inserted (for example, the source file for an image or Shockwave Director movie, or the number of rows and columns in a table). If an object has a parameter form associated with it, you must use the objectTag() function, as it is used to insert values from the form into the returned HTML tags. For example:

'<PARAM NAME="SRC" VALUE="' + document.forms[0].moviesrc.value + '"> \n' +

See Creating an object with a parameters form.


The InsertMenu.htm file
InsertMenu.htm is an HTML file that lists all of the objects that appear in the Insert menu (in the order that they appear), their keyboard shortcuts, and their Windows mnemonics. To function properly, InsertMenu.htm must reside in Configuration/Objects (not in one of the subdirectories).

The file is composed of an unordered list (UL). Each list item (LI) begins with the name of the object as it should appear in the Insert menu, followed by the letter, number, or symbol to use with Control-Alt (Windows) or Command-Option (Macintosh) as a keyboard shortcut, followed by the filename of the object. For example, the entry for Image looks like this in the Document window:

ยท Image, I, image.htm

And like this in the HTML inspector:

<LI><U>I</U>mage, I, image.htm</LI>

The underlined letter (I) is used as a mnemonic for navigating through menus with the keyboard (Windows only).

Submenus are accomplished with nested unordered lists. For example, the Form Object submenu looks like this in the HTML inspector:

<LI>Fo<U>r</U>m Object
<UL>
<LI><U>T</U>ext Field, , textfield.htm
<LI><U>B</U>utton, , button.htm
<LI><U>C</U>heck Box, , checkbox.htm
<LI><U>R</U>adio Button, , radiobutton.htm
<LI><U>L</U>ist/Menu, , listmenu.htm
</UL>

As you can see, keyboard shortcuts are not required, but their comma separators are.


The 16-pixel by 16-pixel GIF image
Each object file has an associated 16-pixel by 16-pixel GIF image that appears in the Object palette. The image file must have the same base name as the object file (for example, object.htm and object.gif) to ensure that the files remain connected.

If you create a larger object image, Dreamweaver will scale it to 16 pixels by 16 pixels.

All of the object images that ship with Dreamweaver were created in the Dreamweaver color scheme (black, white, and gray), but they need not have been. Color is allowed; in fact, colorizing existing object images in graphics or image-editing application may be the easiest way to create new images for any objects you write.